class Solution:
    def findDiagonalOrder(self, nums: list) -> list:
        numMap = {}
        for i in range(len(nums)):
            for j in range(len(nums[i])):
                if i + j not in numMap:
                    numMap[i + j] = []
                numMap[i + j] += [nums[i][j]]
        ans = []
        for n in sorted(numMap.keys()):
            numList = numMap[n]
            for i in range(len(numList) - 1, -1, -1):
                ans.append(numList[i])

        return ans
